/**
 * 获取无为数据
 */
import { reactive } from 'vue';
import { getWuwei } from './serverInterface';
export interface WuweiData{
  data: QuestionData[];
}
export interface QuestionData{
  /* 答案 */
  answer: number;
  /* key */
  id: number;
  /* 答案介绍 */
  introduce: string;
  /* 答案介绍用的图片 */
  introduceImage: string;
  /* 难度级别 */
  level: number;
  /* 选项  */
  option: string[];
  /* 问题 */
  question: string;
  /* 问题所用图片 */
  questionImage: string;
  /* 问题简化版 */
  question_min: string;
}
const wuwei = reactive<WuweiData>({
  data: [],
});
getWuwei({
  schemaid: 'firefighting_day_2021',
}).then((data: QuestionData[]) => {
  data.forEach((question) => {
    question.answer = +question.answer;
    question.option = question.option.toString().split(/\n/);
  });
  wuwei.data = data.sort(() => Math.random() - .5).slice(0, Math.min(5, data.length));
});
export default wuwei;
